package com.xxr.mom.ci.common.dto;

import lombok.Data;

/**
 * @description: Result
 * @date: 2024/8/18 19:20
 * @author: natsuki_kining
 * @version: 1.0
 */
@Data
public class Result<T> {

    /**
     * 200： 成功
     * 其他失败
     */
    private Integer code;

    private String message;

    private T data;

    public Result(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static <T> Result<T> success(T data) {
        return new Result<>(200, "成功", data);
    }

    public static <T> Result<T> fail(Integer code, String message) {
        return new Result<T>(code, message, null);
    }

    public static <T> Result<T> fail(String message) {
        return new Result<T>(500, message, null);
    }
}
